﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoderJoe
{
    public partial class SampleService
        : ServiceBase
    {
        protected SampleModelContainer Context { get; private set; }

        protected SampleService()
        {
        }

        public SampleService(SampleModelContainer context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            Context = context;
        }

        protected override IDisposable CreateServiceContext()
        {
            Context = new SampleModelContainer();

            return new DisposableContainer(
                Context);
        }

        public User FindUserByUserId(int userId)
        {
            return
                (from u in Context.Users
                 where u.UserId == userId
                 select u).FirstOrDefault();
        }
    }
}
